import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import pinia from './store'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import globalComponent from '@/utils/global'
import global2 from '@/utils/global-2'
import 'virtual:svg-icons-register'
import './styles/index.scss'
import directive from './directive'
// 处理加载报错
window.addEventListener('vite:preloadError', (event) => {
    // window.reload() // 例如，刷新页面
    //todo 抛出打印错误，方便查看加载错误信息
    throw new Error(event.payload)
})

const app = createApp(App)
console.log('app', app)
app.use(router).use(pinia)
app.use(ElementPlus)
app.use(globalComponent)
app.use(global2)
// 注册全局指令
app.use(directive)
// 追踪运行时错误
/* app.config.errorHandler = (err, instance, info) => {
    throw new Error(`Error: ${err}, instance: ${instance}, info: ${info}`)
} */
app.mount('#app')
